package com.maegul.web.pages;

import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import com.maegul.data.entities.MediaItem;
import com.maegul.web.components.AudioPlayer;
import com.maegul.web.components.VideoPlayer;
import com.maegul.web.models.HeaderModel;
import com.maegul.web.models.TabHeaderModel;
import com.maegul.web.pages.base.BasePage;

public class PlayerPage extends BasePage {

	private static final long serialVersionUID = 1L;

	public PlayerPage(IModel<PageParameters> params) {
		
		super(new TabHeaderModel(params), new HeaderModel(params));

		String name = params.getObject().get("name").toString();
		MediaItem item = getItemByName(name.trim());

		if (item.getType().equals(ItemTypes.MUSIC)) {
			add(new AudioPlayer("player", item.getMediaSources()));
		} else if (item.getType().equals(ItemTypes.SERIES)
				|| item.getType().equals(ItemTypes.MOVIES))
			add(new VideoPlayer("player", item.getMediaSources()));

	}
}
